package com.yxj.tcpDemo1;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        //tcp协议，发送数据

        //1.创建Socket对象
        //细节：在创建对象的同时会链接服务器
        //如果链接不上，代码会出错
        Socket socket = new Socket("192.168.56.1", 10000);

        //2.可以从链接通道中获取输出流
        OutputStream os = socket.getOutputStream();
        //写出数据
        os.write("abc你好".getBytes());

        //3.释放资源
        os.close();
        socket.close();
    }
}
